from flask import Blueprint
from . import route_func
import os
template_folder = os.path.dirname(__file__)+'/templates'
bp = Blueprint('front', __name__, static_folder='static', url_prefix='/front',template_folder=template_folder)

# 检查用户token
bp.before_request(route_func.check_token)
# 释放资源
bp.after_request(route_func.after_request_func)
# 验证码
bp.add_url_rule('/code', view_func=route_func.code, methods=['GET'])
# 登录
bp.add_url_rule('/login', view_func=route_func.login, methods=['POST'])
# 注册
bp.add_url_rule('/register', view_func=route_func.register, methods=['POST'])
# 获取用户信息
bp.add_url_rule('/user/<int:id>', view_func=route_func.user, methods=['GET','PUT'])
# 首页频道
bp.add_url_rule('/index_channel',view_func=route_func.index_channel,methods=['GET'])
# 频道分类
bp.add_url_rule('/channel_cate/<int:channel_id>',view_func=route_func.channel_category,methods =['GET'])
# 文件上传
bp.add_url_rule('/user_upload', view_func=route_func.upload_user_avatar, methods=['GET','POST'])
# 获取书信息
bp.add_url_rule('/books', view_func=route_func.book_list, methods=['POST'])